from . import app_rendering
from flask import render_template, request

from company.api_mysql import ApiMysqlclass

import json


@app_rendering.route('/')

def index():
    
    page = request.args.get('page')

    limit = request.args.get('limit')

    party = request.args.get('party')

    token = request.args.get('token')

    if party == None:

        party = 'A'

    sql = 'select * from company limit %s,%s '

    info = ApiMysqlclass().get_return(sql, page, limit, party)


    if page == None or page == '1':

        pre_page = 1

        next_page = 2

    else:

        pre_page = int(page) - 1

        next_page = int(page) + 1

    
    info = info['resultBody']

    for i in info:#处理时间

        i['regedate'] = i['regedate'].strftime('%m-%d')



    return render_template('index.html', 
                            info = info, party = party, token = token,
                            pre_page = pre_page, next_page = next_page)

